<?php

use yii\db\Migration;

class m180615_090634_alter_admin_log extends Migration
{
    private function createDb(){
        $dbs = [];
        $dbs_info =\Yii::$app->params['db'];
        foreach($dbs_info as $k=>$v){
            $dbs[$k] = \Yii::createObject($v);
        }
        return $dbs;
    }

    public function safeUp(){
        $dbs = $this->createDb();
        foreach ($dbs as $v) {
            $this->db = $v;
            $this->renameColumn('{{%admin_log}}', 'operate_at', 'created_at');
        }
    }

    public function safeDown()
    {
        $dbs = $this->createDb();
        foreach ($dbs as $v) {
            $this->db = $v;
            $this->renameColumn('{{%admin_log}}', 'created_at', 'operate_at');
        }
    }
}
